
'use strict';
angular.module('SmartAdmin.HttpService').factory('HttpService', ['Restangular', function (Restangular) {

    //�õ����ݿ����е�����
    var _restUserGetAll = Restangular.one('crud', 'getall');

    return {

        Crud: function (operation, data, tableName) {
            if (operation == 'create') {
                var _restCreateTable = Restangular.one('crud', 'createTable');
                return _restCreateTable.post(tableName,'');
            }
            else if (operation == 'drop') {
                var _restDropTable = Restangular.one('crud', 'dropTable');
                return _restDropTable.post(tableName,'');
            }
            else if (operation == 'addcolumn') {

                var _restAddColumn = Restangular.one('crud', 'addColumn');
                return _restAddColumn.post(tableName, data);

            }
            else if (operation == 'modifycolumn') {

                var _restModifyColumn = Restangular.one('crud', 'modifyColumn');
                return _restModifyColumn.post(tableName, data);

            }
            else if (operation == 'dropcolumn') {

                var _restDropColumn = Restangular.one('crud', 'dropColumn');
                return _restDropColumn.post(tableName, data);

            }

            else if (operation == 'update') {
                var _restUpdateOne = Restangular.one('crud', 'replaceOne');
                return _restUpdateOne.post(tableName, data);
            }

            else if (operation == 'updateMore') {
                var _restUpdateOne = Restangular.one('crud', 'updateMoreRowsSensor');
                return _restUpdateOne.post(tableName, data);
            }

            else if (operation == 'add') {
                var _restUserAddOne = Restangular.one('crud', 'insertOne');
                return _restUserAddOne.post(tableName, data);
            }
            
            else if (operation == 'del') {
                var _restUserDelOne = Restangular.one('crud', 'delOne');
                return _restUserDelOne.post(tableName, data);

            }
            else if (operation == 'delMore') {
                var _restUserDelOne = Restangular.one('crud', 'delMoreRowsSensor');
                return _restUserDelOne.post(tableName, data);

            }
            else if (operation == 'query') {

                var _restUserQuery = Restangular.one('crud', 'getWhereData');
                return _restUserQuery.post(tableName, data);

            }
            else if (operation == 'pagination') {
                var _restPagination = Restangular.one('crud', 'pagination');
                return _restPagination.post(tableName, data);

            }

        },

        getDataList: function (tableName) {
            return _restUserGetAll.getList(tableName);

        },

        postData: function (data) {

            return _restAddOne.post(data);
            // return Restangular.one('user/operationtable', con).post('replies', data);
        },

        addOne: function (data, tableName) {

            var _restAddOneConmpany = Restangular.one('crud', tableName);


        }




    }

}]);


